-
Notifications
You must be signed in to change notification settings - Fork 385
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Only move meta tags to the head when required and add processing for meta[http-equiv] #4505
Conversation
$meta_element->parentNode->removeChild( $meta_element ); | ||
} | ||
|
||
continue; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why continue
?
*/ | ||
if ( | ||
$meta_element->hasAttribute( 'name' ) && | ||
preg_match( '/(^|\\s)(amp-.*|amp4ads-.*|apple-itunes-app|content-disposition|revisit-after|viewport)(\\s|$)/', $meta_element->getAttribute( 'name' ) ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It makes me nervous to hard-code this here. It seems better to grab it from the spec.
@pierlon Please review my additions. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @westonruter, fetching the deny pattern from the spec makes things much more robust 👍 .
* @return string Deny pattern. | ||
*/ | ||
private function get_body_meta_tag_name_attribute_deny_pattern() { | ||
static $pattern = null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My initial method of directly supplying the pattern was indeed brittle in retrospect. Getting the pattern from the spec and making it static is much more robust.
@@ -30,7 +61,42 @@ public function get_data_for_sanitize() { | |||
|
|||
$amp_boilerplate = amp_get_boilerplate_code(); | |||
|
|||
return [ | |||
$meta_charset = '<meta charset="utf-8">'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These tests here are much more extensive than what I had before and covers the happy path of execution, along with potential mishaps that may occur 👍.
Pre-release build for testing: amp.zip (1.5.2-alpha-20200402T153920Z-03af649a3) |
…meta[http-equiv] (#4505) * Do not process generic meta tags * Obtain non-body meta name attribute pattern from spec * Make use of BODY_ANCESTOR_META_TAG_SPEC_NAME constant * Test meta[schema] and meta[property] * Add recognition and repositioning of meta[http-equiv] elements * Add critical use_document_element=true arg for AMP_Tag_And_Attribute_Sanitizer * Add tests for the discrete spec'ed meta tags Co-authored-by: Weston Ruter <westonruter@google.com>
Fix verified by user: https://wordpress.org/support/topic/error-in-structured-data-4/page/2/#post-12619449 |
* tag '1.5.2': Bump 1.5.2 Bump version to 1.5.1-RC1 Cache response status and headers when fetching external stylesheets (#4509) Fix securing multi-line mustache templates (#4521) Add CSS monitoring time series to Site Health debugging info (#4519) Update hostname used for WordPress TV embeds to fix external HTTP requests (#4524) Fix processing of element child sanitization loop when invalid elements are replaced with children (#4512) Account for more YouTube URL formats (#4508) Update selected featured image ID on select (#4453) Raise default threshold for disabling CSS caching (#4513) Cast i-amphtml-intrinsic-sizer dimensions to integers (#4506) Only move meta tags to the head when required and add processing for meta[http-equiv] (#4505) Fix failing tests (#4507) Bump 1.5.2-alpha
Summary
Fixes #4502.
meta
tags to thehead
when they are required to be moved; allow other tags to be in thebody
(in particular HTML5 Microdata tags).meta[http-equiv]
tags.meta
tags.Checklist